layui.use(['jquery', 'form', 'layer', 'table', 'element', 'util'], function () {
    var $ = layui.jquery;
    var form = layui.form;
    var layer = layui.layer;
    var element = layui.element;
    var table = layui.table;
    var util = layui.util;

    //头部事件
    util.event('lay-header-event', {  //util 记得 声明 var util = layui.util
        //左侧菜单事件 - 隐藏显示左侧菜单栏
        menuLeft: function (othis) {
            var btn = $("#leftEnumIcon");
            if (btn.hasClass('layui-icon-shrink-right')) {
                menuHide(btn);
                btn.addClass('btn-index');
            } else if (btn.has('layui-icon-spread-left')) {
                btn.removeClass('btn-index');
                menuShow(btn);
            }

            $(window).resize(function () {
                var width = $(document.body).width();
                var btn = $("leftEnumIcon");
                if (width < 1000) {
                    if (btn.hasClass('layui-icon-spread-left')) {
                        menuShow(btn);
                    }
                } else {
                    if (!btn.hasClass('btn-index')) {
                        if (btn.hasClass('layui-icon-shrink-right')) {
                            menuHide(btn);

                        }
                    }
                }
            });

            function menuShow(btn) {
                btn.removeClass('layui-icon-spread-left').addClass('layui-icon-shrink-right');
                $(".layui-side").animate({width: 'toggle'});
                $(".zq-logo").animate({width: 'toggle'});
                $(".layui-body").animate({left: '200px'});
                $(".layui-footer").animate({left: '200px'});
            }

            function menuHide(btn) {
                btn.removeClass('layui-icon-shrink-right').addClass('layui-icon-spread-left');
                $(".layui-side").animate({width: 'toggle'}); //toggle如果原来div是隐藏的就会把元素显示，如果原来是显示则隐藏
                $(".zq-logo").animate({width: 'toggle'});
                $(".layui-body").animate({left: '0px'});
                $(".layui-footer").animate({left: '0px'});
            }
        }
    });
})